package ai.people.netmon.ethereum.monitor.controller;


import ai.people.netmon.ethereum.monitor.service.EthereumUsersService;
import ai.people.netmon.framework.domain.common.monitor.MonitorUsersListVO;
import ai.people.netmon.framework.domain.common.monitor.MonitorUsersVO;
import ai.people.netmon.framework.domain.ethereum.monitor.entity.EthereumUsers;
import ai.people.netmon.framework.domain.ethereum.monitor.request.QueryRequest;
import ai.people.netmon.framework.model.response.PageResponse;
import ai.people.netmon.framework.model.response.Result;
import ai.people.netmon.framework.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
   监测 Ethereum用户信息接口
 *
 * @author zhenglin
 * @since 2022-03-14
 */
@RestController
@RequestMapping("/monitor/user")
public class EthereumUsersController {

    @Autowired
    EthereumUsersService ethereumUsersService;

    /**
     * 分页查询
     *
     * @param request 请求
     * @return {@link Result}<{@link PageResponse}<{@link EthereumUsers}>>
     */
    @PostMapping("/list")
    public Result<PageResponse<MonitorUsersListVO>> list(@RequestBody QueryRequest request){
        PageResponse<MonitorUsersListVO> response = ethereumUsersService.listPage(request);
        return ResultUtil.success(response);
    }

    /**
     * 通过id获取用户信息
     *
     * @param uid uid
     * @return {@link Result}<{@link MonitorUsersVO}>
     */
    @GetMapping("/{uid}")
    public Result<MonitorUsersVO> getUsers(@PathVariable("uid") String uid){
        MonitorUsersVO users = ethereumUsersService.getUsers(uid);
        return ResultUtil.success(users);
    }
}
